<?php
class Admin_Model_DbTable_Role extends Zend_Db_Table_Abstract {
	protected $_name = 'role';
	public function addRole($role_name, $description, $status) {
		$data = array (
				'ROLE_NAME' => $role_name,
				'DESCRIPTION' => $description,
				'STATUS' => $status 
		);
		return $this->insert ( $data );
	}
	public function updateRole($id, $role_name, $description, $status) {
		$data = array (
				'ROLE_NAME' => $role_name,
				'DESCRIPTION' => $description,
				'STATUS' => $status 
		);
		return $this->update ( $data, "ID = $id" );
	}
	public function updateStatus($id, $status) {
		$data = array (
				'STATUS' => $status 
		);
		return $this->update ( $data, "ID = $id" );
	}
	public function getAllRole() {
		return $this->fetchAll ( "STATUS = 1" )->toArray ();
	}
	public function removeRole($id) {
		return $this->delete ( "ID = $id" );
	}
	public function getRoleByName($role_name, $status) {
		return $this->fetchRow("ROLE_NAME = $role_name AND STATUS = $status")->toArray();
	}
	public function getRoleById($id, $status) {
		return $this->fetchRow("ID = $id AND STATUS = $status")->toArray();
	}
	public function getRoleByStatus($status) {
		return $this->fetchAll("STATUS = $status")->toArray();
	}
}

